<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('失败记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px;">代理编号：</label>
                                <input type="text" name="agentNum"/>
                            </li>
                            <li>
                                <label style="width: 100px;">代理名称：</label>
                                <input type="text" name="agentName"/>
                            </li>
                            <li>
                                <label style="width: 100px;">扣款类型：</label>
                                <select name="man">
                                    <option value="">请选择</option>
                                    <option value="admin">服务费扣款</option>
                                    <option value="tj">高签分润扣款</option>
                                    <option value="yf">月返扣款</option>
                                    <option value="bt">达标返现补贴扣款</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 100px;">扣款状态：</label>
                                <select name="status">
                                    <option value="">所有</option>
                                    <option value="0">失败</option>
                                    <option value="1">成功</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label style="width: 100px;">扣款日期：</label>
                                <input type="text" class="time-input" readonly placeholder="开始时间" name="start"/>
                                <span>-</span>
                                <input type="text" class="time-input" readonly placeholder="结束时间" name="end"/>
                            </li>
                            <li>
                                <label style="width: 10px;"></label>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
<!--
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="agentInfo:kouFail:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="agentInfo:kouFail:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="agentInfo:kouFail:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="agentInfo:kouFail:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('agentInfo:kouFail:edit')}]];
        var removeFlag = [[${@permission.hasPermi('agentInfo:kouFail:remove')}]];
        var prefix = ctx + "agentInfo/kouFail";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "失败记录",
                firstLoad:true,
                clickToSelect:true,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'pk_id',
                    visible: false
                },
                {
                    field: 'agentNum',
                    title: '代理编号'
                },
                {
                    field: 'agentName',
                    title: '代理名称'
                },
                {
                    field: 'money',
                    title: '金额'
                },
                {
                    field: 'man',
                    title: '类型',
                    formatter:function (value, row, index) {
                        if (value == 'admin'){
                            return '<span style="color: red">服务费扣款</span>';
                        } else if (value == 'tj'){
                            return '<span style="color: green">高签分润扣款</span>';
                        } else if (value == 'yf'){
                            return '<span style="color: blue">月返扣款</span>';
                        } else if (value == 'bt'){
                            return '<span style="color: green">达标返现补贴扣款</span>';
                        }
                    }
                },
                {
                    field: 'createDate',
                    title: '创建日期'
                },
                {
                    field: 'sendDate',
                    title: '出款时间'
                },
                {
                    field: 'status',
                    title: '出款状态',
                    formatter:function (value, row, index) {
                        if (value == '0'){
                            return '<span style="color: red">失败</span>';
                        } else if (value == '1'){
                            return '<span style="color: green">成功</span>';
                        }
                    }
                },
                {
                    field: 'note',
                    title: '备注'
                },
                {
                    field: 'addMan',
                    title: '操作人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="saveCk(\'' + row.id + '\')"><i class="fa fa-edit"></i>扣款</a> ');
/*
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


        /**
         * 失败再扣款
         */
        function saveCk(id) {
           $.modal.confirm("确定要进行扣款吗?", function() {
               $.post(prefix + "/saveCk",{'id':id},function(result){
                   if (result.code == '0'){
                       $.modal.msgSuccess(result.msg);
                   } else {
                       $.modal.msgError(result.msg);
                   }
                   $.table.refresh();
               });
           })
       }

    </script>
</body>
</html>